import java.util.ArrayList;
import java.util.List;

public class Solution {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> tmp = new ArrayList<>();
        tmp.add(1);
        ret.add(tmp);
        for(int i = 1; i < numRows; i++){
            List curList = new ArrayList<>(i + 1);
            for(int j = 0; j < i + 1; j++){
                if(j == 0 || j == i + 1 - 1){
                    curList.add(1);
                }else{
                    List<Integer> preList = ret.get(i - 1);
                    curList.add(preList.get(j - 1) + preList.get(j));
                }
            }
            ret.add(curList);
        }
        return ret;
    }




    public static void main(String[] args) {
//        Solution solution = new Solution();
//        solution.generate(5);
    }
}
